home *** CD-ROM | disk | FTP | other *** search
/ Libris Britannia 4 / science library(b).zip / science library(b) / DDJMAG / DDJ9207.ZIP / ACOMP.ZIP / DOSCALLS.H < prev    next >
Text File  |  1991-12-17  |  11KB  |  178 lines

  1. /******************************************************************************/
  2. /* DOSCALLS.ASM, DOSCALLS.H                              */
  3. /* Written by John W. Ratcliff, December 1991.                      */
  4. /******************************************************************************/
  5. /* DOSCALLS is a linkable object module that provides many of the functions   */
  6. /* available through the standard C libraries.    There are number of reasons to*/
  7. /* use DOSCALLS.OBJ rather than C library function calls.              */
  8. /*                                          */
  9. /*     1. Portability: These functions work the same regardless of what     */
  10. /*             C compiler you are using.                  */
  11. /*                                          */
  12. /*     2. Size:     These functions are extremely small compared to      */
  13. /*             equivalent C library functions. The C library          */
  14. /*             functions are general while the DOSCALLS          */
  15. /*             function calls are very specific.  Accessing C       */
  16. /*             library function calls causes large amounts of       */
  17. /*             library code to get drug in that you probably          */
  18. /*             don't want.                                          */
  19. /*                                          */
  20. /*     3. TSR capability: If you program TSR's you will find that           */
  21. /*             dragging in C library functions will kill you          */
  22. /*             for a whole number of reasons.  Using              */
  23. /*             DOSCALLS.OBJ you have no DGROUP dependencies and     */
  24. /*             you can easily write single segment TSR's and        */
  25. /*             even write both COM modules and DOS device          */
  26. /*             drivers.                          */
  27. /*                                          */
  28. /*     4. Assembly language:    If you don't program in C and need basic      */
  29. /*             DOS support functions, you can just use DOSCALLS     */
  30. /*             for this purpose.                      */
  31. /*                                          */
  32. /*     5. Simplicity:  DOSCALLS don't ignore the fact that you are programming*/
  33. /*             on an MS-DOS machine.    They in fact simply provide   */
  34. /*             C callable access to INT 21h calls.  Because of this */
  35. /*             they are all easy to use.                  */
  36. /******************************************************************************/
  37. #define NEW_FILE 0 // MFOPEN file types, 0 open as a new file for read/write
  38. #define OLD_FILE 1 // file type 1, open as an old file for read/write access
  39. #define FILE_NOT_FOUND 0 // file handle of zero, is file not found.
  40.  
  41. int  far mfopen(char far *filename,long int far *size,int type);
  42. /******************************************************************************/
  43. /* mfopen -> Does a DOS file open.  Returns a DOS file handle, which is simply*/
  44. /*         an integer.  You can open a file as a new file or as an old file */
  45. /*         by specifying the file type.  A return code of zero means that   */
  46. /*         the file couldn't be opened.  You pass the address of a long int */
  47. /*         who's contents will be filled with the total length of the file. */
  48. /*         If you pass a null address then the size will not be reported.   */
  49. /*         After a file open, the file pointer will always be sitting at    */
  50. /*         byte position zero.                          */
  51. /******************************************************************************/
  52.  
  53. int  far mfclose(int fhand);
  54. /******************************************************************************/
  55. /* mfclose -> Close a file that was opened with mfopen.               */
  56. /******************************************************************************/
  57.  
  58. long int  far mfpos(int fhand);
  59. /******************************************************************************/
  60. /* mfpos -> report current file position of this file.                  */
  61. /******************************************************************************/
  62.  
  63. long int far mfseek(int fhand,long int fpos);
  64. /******************************************************************************/
  65. /* mfseek -> seek file to this position passed.  Return code is actual file   */
  66. /*         seek position achieved. (In case request went past end of file.) */
  67. /******************************************************************************/
  68.  
  69. int  far mfread(void far *address,long int size,int fhand);
  70. /******************************************************************************/
  71. /* mfread -> read from file, into address, for length of size, from fhand.    */
  72. /*         return code of 1, successful file read, return code of zero,     */
  73. /*         file read failed.                              */
  74. /******************************************************************************/
  75.  
  76. int  far mfwrite(void far *address,long int size,int fhand);
  77. /******************************************************************************/
  78. /* mfwrite -> write data to file, from address, for length of size, to fhand. */
  79. /*          return code of 1, success, return code of zero, write failed.   */
  80. /******************************************************************************/
  81.  
  82. char far * far fload(char far *name,long int far *siz);
  83. /******************************************************************************/
  84. /* fload -> allocate memory, and read entire file in.  Uses name as filename  */
  85. /*        and returns the length read in, in siz.  If siz is null then siz  */
  86. /*        not set.  If return code is NULL then was unable to load file.    */
  87. /*        Either the file wasn't found, or there wasn't enough memory to    */
  88. /*        read it in.  Otherwise return code is the address of the file     */
  89. /*        read in at.  Uses MEMALLOC (provided by application program) to   */
  90. /*        allocate memory, and caller must do MEMFREE when finished with    */
  91. /*        this memory.                              */
  92. /******************************************************************************/
  93.  
  94. char far * far floadpara(char far *name,long int far *siz,int far *segment);
  95. /******************************************************************************/
  96. /* floadpara -> a special version of fload, that reads in the file into       */
  97. /*        allocated memory, but forces it at a paragraph boundary.      */
  98. /*        The return code is still the address of allocated memory for  */
  99. /*        the file read, but the variable segment is loaded with the    */
  100. /*        actual segment boundary that the file was read in at.  This   */
  101. /*        is used by digplay's LoadDriver call, which loads a binary    */
  102. /*        image into memory, that must fall on a paragraph boundary.    */
  103. /******************************************************************************/
  104.  
  105. int  far keystat(void);
  106. /******************************************************************************/
  107. /* keystat-> report DOS key status.  Zero, no key pending, 1, key pending.    */
  108. /******************************************************************************/
  109.  
  110. int  far getkey(void);
  111. /******************************************************************************/
  112. /* getkey -> DOS getkey function. Returns keypress pending.  Automatically    */
  113. /*         handles extended key codes, by adding 256 to them.           */
  114. /******************************************************************************/
  115.  
  116. void far farcop(char far *dest,char far *source);
  117. /******************************************************************************/
  118. /* farcop -> string copy routine, but uses far pointers.              */
  119. /******************************************************************************/
  120.  
  121. void far farcat(char far *dest,char far *source);
  122. /******************************************************************************/
  123. /* farcat -> string concatenate routine, but with far pointers.           */
  124. /******************************************************************************/
  125.  
  126. int far farlen(char far *string); // Return length of string.
  127.  
  128. int far farcompare(char far *source,char far *dest); // String compare.
  129.  
  130. void far ucase(char far *string); // Upper case a string.
  131.  
  132. char far * far fmalloc(long int size);
  133. /******************************************************************************/
  134. /* fmalloc -> DOS memory allocation.  Works fine by itself but conflicts with */
  135. /*          C compiler's far memory allocation.  DOS likes memory to be     */
  136. /*          de-allocated in the order that it was originally allocated, in  */
  137. /*          order for it to cleanly defragment memory pools.    These function*/
  138. /*          calls are valid if you are writing a TSR or must do DOS memory  */
  139. /*          allocation exclusively.                          */
  140. /******************************************************************************/
  141.  
  142. void far ffree(char far *tmp);
  143. /******************************************************************************/
  144. /* ffree -> free dos allocated memory.                          */
  145. /******************************************************************************/
  146.  
  147. void far writeln(char far *string);
  148. /******************************************************************************/
  149. /* writeln -> echo a string to the console.  Avoids dragging all of the printf*/
  150. /*          library code, which is HUGE!                      */
  151. /******************************************************************************/
  152.  
  153. void far * far GetTimerInterruptVector(void);
  154. /******************************************************************************/
  155. /* GetTimerInterruptVector -> reports the current far address of the timer    */
  156. /*        interrupt vector.  This function call is used to report the       */
  157. /*        original address of the timer interrupt vector, should your       */
  158. /*        application choose to change it.  These services are provided     */
  159. /*        because some of the sound drivers use the Timer interrupt to play */
  160. /*        back sound.  (Use AudioCapabilities to find out which ones.)  Even*/
  161. /*        though the sound drivers all still service the original 18.2 timer*/
  162. /*        interrupt, some application software may have already modified    */
  163. /*        the timer for it's own purposes.  In these cases you will         */
  164. /*        want to disable that timer while digitized sound playback is      */
  165. /*        occuring, and then put it back when sound playback has completed. */
  166. /*        If your application doesn't reprogram the timer interrupt vector  */
  167. /*        rate, you needn't worry about any of this stuff.                  */
  168. /******************************************************************************/
  169.  
  170. void far SetTimerInterruptVector(void far *address,unsigned int divisor);
  171. /******************************************************************************/
  172. /* SetTimerInterruptVector -> set the timer interupt vector to a new address  */
  173. /*         and specify a new interupt rate.                      */
  174. /******************************************************************************/
  175.  
  176. int far mdelete(char far *fname); // Delete a file by filename.
  177. int far ifexists(char far *fname);    // Does this file exist? 1 yes, 0 no.
  178.